<?xml version='1.0' encoding='UTF-8' ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <body>
        <ui:composition template="./../Template/generalTemplate.xhtml">
            <ui:define name="content">
                <h:form>
                    <p:panel id="addSalesman" header="Add New Salesman" style="height:495px;">
                        <div style="margin-left:350px;margin-top:30px;">
                            <h:panelGrid id="grid" columns="3">
                                <h:outputText value="UserName:"/>
                                <h:inputText required ="true" requiredMessage="User Name cannot be empty" value="#{addSalesmanManagedBean.salesman.userName}"/>
                                <br/>
                                <h:outputText value="Name:"/>
                                <h:inputText required ="true" requiredMessage="Name cannot be empty" value="#{addSalesmanManagedBean.salesman.name}"/>
                                <br/>
                                <h:outputText value="Password:"/>
                                <h:inputSecret required ="true" requiredMessage="Password cannot be empty" redisplay="true" value="#{addSalesmanManagedBean.salesman.password}"/>
                                <br/>
                                <h:outputText value="DOB(DD-MM-YYYY):"/>
                                <p:inputMask required ="true" requiredMessage="DOB cannot be empty" value="#{addSalesmanManagedBean.salesman.DOB}" mask="99-99-9999"/>
                                <br/>
                                <h:outputText value="Department:"/>
                                <h:selectOneMenu id="companyId" value="#{addSalesmanManagedBean.salesman.department}" required="true" requiredMessage="Department Cannot be Blank" style="width:170px;">
                                    <f:selectItem itemLabel="Sales" itemValue="Sales" />
                                </h:selectOneMenu>
                                <br/>
                                <h:outputText value="ContactNumber:"/>
                                <p:inputMask required ="true" requiredMessage="Contact Number cannot be empty" value="#{addSalesmanManagedBean.salesman.contactNumber}" mask="(99)99999999"/>
                                <br/>
                                <h:outputText value="Salesman Level:"/>
                                <h:selectOneMenu id="salesmanLevel" value="#{addSalesmanManagedBean.salesman.salesManLevel}" required="true" requiredMessage="Salesman Level Cannot be Blank" style="width:170px;">
                                    <f:selectItem itemLabel="1" itemValue="1" />
                                    <f:selectItem itemLabel="2" itemValue="2" />
                                    <f:selectItem itemLabel="3" itemValue="3" />
                                    <f:selectItem itemLabel="4" itemValue="4" />
                                </h:selectOneMenu>
                                <br/>
                                <h:outputText value="Roles"/>
                                <h:selectManyMenu value="#{addSalesmanManagedBean.selectedRoles}" style="height:100px;width:170px;">  
                                    <f:selectItems value="#{addSalesmanManagedBean.roleManager.allRoles}"  
                                                   var="allRoles" itemLabel="#{allRoles.roleName}" 
                                                   itemValue="#{allRoles.id}" />  
                                </h:selectManyMenu>  
                            </h:panelGrid><br />
                            <p:commandButton value="Save" ajax="true" update="statusMessages addSalesman" actionListener="#{addSalesmanManagedBean.saveNewSalesman}"/>
                            <p:commandButton value="Add More Salesmen" actionListener="#{addSalesmanManagedBean.oneMore}" rendered="#{addSalesmanManagedBean.show}"/>
                        </div>
                    </p:panel>
                </h:form>
            </ui:define>

            <ui:define name="bottom">
                <p:messages id ="statusMessages"/>
            </ui:define>

        </ui:composition>
    </body>

</html>
